<?php defined('SYSPATH') or die('No direct access allowed.');


class Model_Project_Tag extends ORM {

		// Relationships
	protected $_belongs_to = array('project' => array('model' => 'desktop_project','foreign_key' => 'project_id'));

        public function rules()
	{
		return array(
			'name' => array(
				array('not_empty'),
				array('max_length', array(':value', 50)),
			)                    
		);
	}
        
        public function filters()
	{
		return array(
			'name' => array(
                                //xss clean
				array(array('Security', 'xss_clean')),
                                array('trim')
			)              
		);
	}
        
        public function labels()
	{
		return array(
			'name'         => __('Tag')
		);
	}
        
        public function get_tags($project_id)
        {
            return DB::select('id', 'name')->where('project_id', '=', $project_id)
                               ->from('project_tags')
                               ->as_object()
                               ->execute();
        }
}